<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<?php
	class Order extends Controller{
			function order(){
				
					parent::Controller();
					$this->load->library('session');
					$this->load->helper('url');
							}
			function index(){
					$this->load->database();
					
				}
				
			function buy(){
					if($this->session->userdata('username')==""){
					
						echo "<script language='JavaScript'>alert('请返回登录');history.back();</script>";
																}
																
							else{
								
									$post=$_POST;
									//print_r($post);
									$this->load->view('html/order',$post);
								}
						  }
			function create_order(){
				
					$data=array();
					$data=array(
									'username'=>$this->session->userdata['username'],
									'proid'=>$this->session->userdata['proid'],
									'price'=>$this->session->userdata['price']*$_POST['nums'],
									'content'=>$_POST['order_info'],
									'times'=>time(),
									'status'=>1,
									'product_name'=>$this->session->userdata['product_name'],
								
					);
					
					//print_r($data);
					$this->load->model('ordermodel');
					$this->ordermodel->create_order('gaoji_shophistory',$data);
					echo "<script language='JavaScript'>alert('已经下单，给钱啦！');</script>";
					
				}
				
			function view_order(){
								$this->load->model('ordermodel');
								$data['query']=$this->ordermodel->select_order($this->session->userdata['username']);
								$this->load->view('html/my_order',$data);
				
				}
			
			function admin_view_order(){
								$this->load->model('ordermodel');
								$data['query']=$this->ordermodel->select_all_order();
								$this->load->view('admin_order',$data);
					
				}
		}

?>
</body>
</html>